package com.intro.util;

import java.util.List;


/**
 * 分页对象
 * project:MobileIdc
 * @author einarzhang
 * @version 1.0   2011-12-12
 * @since MobileIdc1.0
 */
public class Page {

	/*** 记录总数 */
	protected int totalRecords;
	/*** 一页显示的记录数 */
	protected int pageSize;
	/*** 当前页 */
	protected int currentPage;
	/*** 总页数 */
	protected int totalPages;
	/*** 存储当前页数据的列表 */
	@SuppressWarnings("unchecked")
	protected List pageList;
	
	@SuppressWarnings("unchecked")
	/**
	 * 构造函数
	 * @param pageSize
	 * @param currentPage
	 * @param totalRecords
	 * @param pageList
	 */
	public Page(int pageSize, int currentPage, int totalRecords, List pageList) {
		this.pageSize = pageSize;
		this.currentPage = currentPage;
		this.totalRecords = totalRecords;
		this.pageList = pageList;

		// 获取总页数
		if (totalRecords % pageSize == 0) {
			this.totalPages = totalRecords / pageSize;
		} else {
			this.totalPages = totalRecords / pageSize + 1;
		}
		if (totalPages == 0) {
			totalPages = 1;
		}
	}
	
	public Page() {
	}
	
	public int getTotalRecords() {
		return totalRecords;
	}

	public void setTotalRecords(int totalRecords) {
		this.totalRecords = totalRecords;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	@SuppressWarnings("unchecked")
	public void setPageList(List pageList) {
		this.pageList = pageList;
	}

	@SuppressWarnings("unchecked")
	public List getPageList() {
		return pageList;
	}
}
